//
// Created by root on 01/04/17.
//

#ifndef IMG_SVR_TEMP_CLEAN_H
#define IMG_SVR_TEMP_CLEAN_H

#include "common.hpp"
#include "Poco/Util/TimerTask.h"
#include "Poco/Util/Timer.h"

namespace img_svr {
    class CleanImpl : public Poco::Util::TimerTask {
    public:
        CleanImpl(string& root_path,int& before_days):_root_path(root_path),_before_days(before_days){}
        void run();

    private:
        string _root_path;
        int _before_days;
    };

    class CleanTempFile {
    public:
        void Start();

        void Init(string root_path,int before_days){
             _clean_impl_ptr = new CleanImpl(root_path,before_days);
        }
        static CleanTempFile &Instance() {
            static CleanTempFile clean;
            return clean;
        };
    private:
        CleanTempFile() {

        }
        CleanImpl::Ptr _clean_impl_ptr;
        Poco::Util::Timer _timer;
    };
}

#endif //IMG_SVR_TEMP_CLEAN_H
